package com.tongji.seller.model
{ 
	import com.adobe.serialization.json.JSON;
	import com.tongji.seller.vo.ObjectTranslator;
	import com.tongji.seller.vo.Type;
	
	import mx.collections.ArrayCollection;
	import mx.controls.Alert;
	
	import org.robotlegs.mvcs.Actor;
	
	/**
	 * 
	 * @author jiarong
	 * 
	 */
	
	[Bindable]
	public class TypeModel extends Actor
	{
		public var placeStr:String;
		public var styleStr:String;
		public var placeArray:ArrayCollection;
		public var styleArray:ArrayCollection;
		
		
		public function TypeModel()
		{
			super();
		}
		
		/**
		 *更新场地数据 
		 * @param placeStr
		 * 
		 */		
		
		public function updatePlaces(placeStr:String):void
		{
			this.placeStr = placeStr;
			var arr:Array = (JSON.decode(placeStr) as Array);
			var tempArr:Array = new Array();
			for (var i:int = 0; i < arr.length; i++)
			{
				var obj:Object = arr[i] as Object;
				var type:Type = ObjectTranslator.objectToInstance(obj, Type) as Type;
				tempArr.push(type);
			}
			placeArray = new ArrayCollection(tempArr);
		}
		
		/**
		 *更新风格数据 
		 * @param styleStr
		 * 
		 */	
		
		public function updateStyles(styleStr:String):void
		{
			this.styleStr = styleStr;
			var arr:Array = (JSON.decode(styleStr) as Array);
			var tempArr:Array = new Array();
			for (var i:int = 0; i < arr.length; i++)
			{
				var obj:Object = arr[i] as Object;
				var type:Type = ObjectTranslator.objectToInstance(obj, Type) as Type;
				tempArr.push(type);
			}
			styleArray = new ArrayCollection(tempArr);
		}
	}
}